<?php
header("content-type: text/html; charset: utf-8");

//解析config.ini文件
//$config = parse_ini_file(realpath(dirname(__FILE__) . '/config/config.ini'));

//从config 中获取数据库相关属性
//$servername = $config["dbServername"];
//$username = $config["dbUsername"];
//$password = $config["dbPassword"];
//$dbName = $config["dbName"];

//数据库连接
$mysqli = new mysqli("localhost", "root", "gcy888999", "blog");

//检测连接
if(mysqli_connect_error()) {
    die("连接失败: " . $mysqli->connect_error);
}

//mysqli_query($mysqli, "DELETE FROM user WHERE username='gaol'");

$username = 'gaol';
$password = '123456';


 $sql = "SELECT username, password FROM user where username ='".$username. "' AND password='" .$password . "'";
 $result = $mysqli->query($sql);
 if($result->num_rows > 0) {
     while ($row = mysqli_fetch_assoc($result)) {
         echo  $row["username"]. " " .$row["password"]. "<br>";
         header("Location: welcome.html");
     }
 }else {
     echo "0结果";
 }

mysqli_close($mysqli);